package com.blue.fish.tiny.common;

import java.util.regex.Pattern;

/**
 * @author QingFan
 * @version 1.0.0
 * @date 2023年01月09日 20:50
 */
public class AlphabetHelper {

	/**
	 * 字母正则
	 */
	static Pattern ptnLetter = Pattern.compile("^[a-zA-Z]$");
	/**
	 * 数字正则
	 */
	static Pattern ptnNumber = Pattern.compile("^[0-9]$");
	/**
	 * 变量
	 */
	static Pattern ptnLiteral = Pattern.compile("^[_a-zA-Z0-9]$");
	/**
	 * 操作符
	 */
	static Pattern ptnOperator = Pattern.compile("^[*+\\-<>=!&|^%/,]$");

	public static boolean isLetter(char c) {
		return ptnLetter.matcher(c + "").matches();
	}

	public static boolean isNumber(char c) {
		return ptnNumber.matcher(c + "").matches();
	}

	public static boolean isLiteral(char c) {
		return ptnLiteral.matcher(c + "").matches();
	}

	public static boolean isOperator(char c) {
		return ptnOperator.matcher(c + "").matches();
	}

}
